package com.xiaoyu.test;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/05/09 16:28
 **/
public class TicketThread implements Runnable {
    private static Integer ticketCount = 1000;
    private String threadName;

    public String getThreadName() {
        return threadName;
    }

    public void setThreadName(String threadName) {
        this.threadName = threadName;
    }

    public TicketThread(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        synchronized (ticketCount) {
            while (ticketCount > 0) {
                System.out.println("线程" + threadName + "卖出了第" + ticketCount + "张票！");
                ticketCount--;
            }
        }
    }
}
